export function secToFrame(second, rate, multiple = 1) {
  return parseInt(Math.floor(second * rate * multiple))
}

export function frameToSec(frame, rate, digitCount = 2) {
  return parseFloat((frame / rate).toFixed(digitCount))
}

export function getFramePairs(secPairs, rate = 60, multiple = 1) {
  const framePairs = secPairs
    .map((pair) => {
      return [
        secToFrame(pair[0], rate, multiple),
        secToFrame(pair[1], rate, multiple),
      ]
    })
    // vlevin @ 2022-06-29 如果两个数过于相近，将会计算出同样的帧数，导入PR会造成时间线有空隙
    // vlevin @ 2022-06-29 所以必须过滤一遍
    .filter((item) => item[0] < item[1])
  return framePairs
}
